package action;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;

import com.opensymphony.xwork2.ActionSupport;

public class TestAction extends ActionSupport {

	/**
	 * @return
	 */
	private String username;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	private String password;
	private SessionFactory sessionFactory;
	public String execute() {
		// TODO Auto-generated method stub
		System.out.println(username+"kukuku8888888"+password);
		Session session=sessionFactory.openSession();
		String hql="from Student s where s.name=? and s.password=?";
		System.out.println(username+"kukuku8888888"+password);
		Query query=session.createQuery(hql);
		query.setParameter(0, username);
		query.setParameter(1, password);
		System.out.println(username+"kukuku8888888"+password);
		List student=query.list();
		session.close();
		if(student.size()>0){
			return SUCCESS;
		}else{
			System.out.println(username+"kukuku8888888"+password);
			return ERROR;
		}
		//return SUCCESS;
	}
}